﻿@{
    ViewBag.Title = "";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<div class="rows">
    <div class="panel panel-default">
        <table class="form">
            <tr>

                <th class="formTitle">开始日期：</th>
                <td class="formValue">
                    <input id="kssj" type="text" class="form-control input-wdatepicker form-an" style="width: 140px;"
                           onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss'})" value="@(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"))" />
                </td>
                <th class="formTitle" style="padding-right:5px;">结束日期：</th>
                <td class="formValue">
                    <input id="jssj" type="text" class="form-control input-wdatepicker form-an" style="width:140px"
                           onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss' })" value="@(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"))" />
                </td>
                @*<th class="formTitle">收款人：</th>
                <td class="formValue" style="width:200px">
                    <input id="skr" name="rad" type="radio" checked="checked" />本人&nbsp;&nbsp;&nbsp;<input name="rad" id="qb" type="radio" />全部
                </td>*@
                <td class="formValue" style="padding-left:20px;">
                    <input type="button" id="btn_search" onclick="submit();" class="btn btn-primary btn-md" value="查询" style="width:55px" />
                </td>
                <td class="formValue"></td>
            </tr>
        </table>
    </div>
</div>

<div class="ui-layout" id="layout" style="height:100%;width:100%;">
    <iframe class="ui-layout-center" style="width:100%;" id="iframerightiframerightiframerightttt" name="iframerightiframerightiframerightttt"
            scrolling="auto" allowtransparency="true" frameborder="0"></iframe>
</div>

<script type="text/javascript">
    var reportServerHOST = '@(ViewBag.ReportServerHOST)';
    var orgId = '@(ViewBag.OrgId)';
    var isHospAdministrator = '@(ViewBag.IsHospAdministrator)';
    var curUserCode = '@(ViewBag.CurUserCode)';

    //var uri = 'ReportServer/Pages/ReportViewer.aspx?%2fHIS.Report.1%2fchongqing门诊日结账费用表&rs:Command=Render';
    var uri = 'ReportServer/Pages/ReportViewer.aspx?%2fHIS.Report.1%2fchongqing门诊月结表&rs:Command=Render';

    function submit() {

        if ($('#kssj').val().length == 0) {
            $.modalAlert("缺少开始时间", "error");
            return;
        }
        if ($('#jssj').val().length == 0) {
            $.modalAlert("缺少结束时间", "error");
            return;
        }
        if ($('#kssj').val() > $('#jssj').val()) {
            $.modalAlert("开始时间不能大于结束时间", "error");
            return;
        }
        var checkkssj = $('#kssj').val().substring('5', '7');
        var checkjssj = $('#jssj').val().substring('5', '7');
        if (checkkssj != checkjssj) {
            $.modalAlert("查询间隔不能相差一个月", "error");
            return;
        }

        var url = getUrl();
        var usercode = '@ViewBag.CurUserCode';
        
        url += "&kssj=" + $('#kssj').val();
        url += "&jssj=" + $('#jssj').val();
        //if ($('#skr').prop('checked') == true) {
        //    url += "&doctor=" + usercode;
        //}
        //else {
        //    url += "&doctor=";
        //}

        setTimeout("$.loading(true, '正在请求报表页面...');", 10);

        $("#iframerightiframerightiframerightttt").attr('src', url);


    }
    $("#iframerightiframerightiframerightttt").load(function () {
        $.loading(false);
    });

    $(function () {
        var h = $(window).height() - 55
        $('#layout iframe').css('height', h);
      

        setTimeout(function () { submit(); }, 100);
    });

    function getUrl() {
        if (uri.StartWith('/')) {
            uri = uri.substr(1);
        }
        var srcUrl = uri;
        srcUrl = reportServerHOST + srcUrl;

        //获取自定义样式
        if (true) {
            if (srcUrl.indexOf('&rc:') == -1) {
                srcUrl += "&rc:Stylesheet=MyStyleSheet";
            }
        }
        if (true) {
            if (srcUrl.indexOf('&rs:') == -1) {
                srcUrl += "&rs:";
            }
            else {
                srcUrl += "&";
            }
            srcUrl += "orgId=";
            srcUrl += orgId;
        }
        return srcUrl;
    }
</script>